<?php
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/frontend/js/jquery.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/js/bootstrap.min.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerCssFile($this->staticsPath."/css/global.css");
Yii::app()->clientScript->registerCssFile($this->staticsPath."/css/index.css");
Yii::app()->clientScript->registerCssFile($this->staticsPath."/css/font-awesome.min.css");
Yii::app()->clientScript->registerCssFile($this->staticsPath."/Font-Awesome-3.2.1/css/font-awesome.min.css");
Yii::app()->clientScript->registerCssFile($this->staticsPath."/css/bootstrap.min.css");


Yii::app()->clientScript->registerCssFile($this->staticsPath."/css/jquery.timepicker.css");
Yii::app()->clientScript->registerCssFile($this->staticsPath."/css/styles.css");
Yii::app()->clientScript->registerCssFile($this->staticsPath."/css/materialize.min.css");
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/js/materialize.min.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/js/stopwatch.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/js/jquery.timepicker.min.js",CClientScript::POS_HEAD);


Yii::app()->clientScript->registerCss("CSS1","
    .cont_box img{
        height: 200px;
    }

   #loadings {
        left: 50%;
        position: absolute;
        top: 50%;
    }

");


?>
<style type="text/css">
    .main-box {

        height: 100%;
        left: 0;
        margin: 0 auto;
        position: absolute;
        top: 0;
        width: 100%;
        z-index: -1;
    }
    .morcon {
        height: 100px;
        margin: 245px 20px 20px;
        position: relative;
        text-align: center;
    }

    .morcon .reg {
        background: rgba(255, 255, 255, 0) none repeat scroll 0 0;
        border: medium none;
        color: #fff;
        font-size: 20px;
        left: 4%;
        position: absolute;
        top: 0;
    }
    .morcon .login {
        background: rgba(255, 255, 255, 0) none repeat scroll 0 0;
        border: medium none;
        color: #fff;
        display: block;
        font-size: 20px;
        left: 51%;
        position: absolute;
        top: 39%;
    }

    .wrap .header{
        width: 100%;
        position: relative;
        height: 300px;
    }
    .wrap .footer {
        height: 300px;
        position: relative;
        width: 100%;
    }

    .wrap .header .mydodo{
        background: url("<?php echo $this->staticsPath."/img/mydodo.png" ?>") no-repeat scroll 0 0 / 150px auto;
        height: 40px;
        width: 150px;
        position: absolute;
        right: 15px;
        top: 25px;
    }
    .wrap .header .imgbg{
        background: url("<?php echo $this->staticsPath."/img/imgbg.png" ?>") no-repeat scroll 0 0 / 150px auto;
        height: 150px;
        width: 150px;
        position: absolute;
        left: 15px;
        top: 90px;
    }
    .imgbg .box{
        width: 100%;
        height: 100%;
        position: relative;
    }
    .imgbg .box img {
        border-radius: 50%;
        height: 80%;
        left: 15px;
        position: absolute;
        top: 15px;
        width: 80%;
    }
    .wrap .header .hname {
        height: 200px;
        left: 170px;
        position: absolute;
        top: 144px;
        width: 200px;
    }
    .wrap .header .hname p{
        color: #0066b3;
        font-size: 20px;
    }
    .wrap .header .list {


        height: 80px;
        left: 25px;
        position: absolute;
        top: 25px;
        width: 80px;
    }
    .wrap .header .list a{
        color: #0066b3;
        font-size: 30px;
    }
    .wrap .footer .fbotton{
        width: 33%;
        height: 150px;
        float: left;
    }
    .wrap .footer .fbotton .like{
        background: url("<?php echo $this->staticsPath."/img/mylike.png" ?>") no-repeat scroll 13px 0 / 90px auto;
        height: 100%;
        width: 100%;
    }
    .wrap .footer .fbotton .collection{
        background: url("<?php echo $this->staticsPath."/img/mycollection.png" ?>") no-repeat scroll 13px 0 / 104px auto;
        height: 100%;
        width: 100%;
    }
    .wrap .footer .fbotton .share{
        background: url("<?php echo $this->staticsPath."/img/share.png" ?>") no-repeat scroll -2px 15px / 114px auto;
        height: 100%;
        width: 100%;
    }
    .wrap .footer .fbotton .point{
        background: url("<?php echo $this->staticsPath."/img/point.png" ?>") no-repeat scroll 6px 0 / 104px auto;
        height: 100%;
        width: 100%;
    }
    .wrap .footer .fbotton .pointlist{
        background: url("<?php echo $this->staticsPath."/img/pointlist.png" ?>") no-repeat scroll 13px 0 / 90px auto;
        height: 100%;
        width: 100%;
    }
    .wrap .footer .fbotton .pointgift{
        background: url("<?php echo $this->staticsPath."/img/pointgift.png" ?>") no-repeat scroll 13px 11px / 90px auto;
        height: 100%;
        width: 100%;
    }
    body{
        background: #f4f4f4 none repeat scroll 0 0;
    }
    .topban{
        padding: 0 10px
    }
    .topban .top {
        color: #888;
        height: 20px;
        left: 50%;
        line-height: 20px;
        margin: -10px 0 52px -30px;
        position: absolute;
        top: 50%;
    }
    .topban .top.name {
        margin-top: -30px;
    }
    .topban .top.num {
        margin-top: -5px;
    }
    .topban .top.subject {
        margin-top: 20px;
    }
    #logout{
        color: #ffffff;
        font-size: 18px;
    }
    #logout:hover{
        color: #ffffff;
    }
    .lgt{
        width: 90%;
        height: 50px;
        text-align: center;
        margin: 20px auto 0 auto;
        margin-bottom: 50px;
        background: rgb(231,66,60);
        border-radius: 8px;
        line-height: 50px;
    }
    .right{
        float: right;
        margin-top: 10px;
    }
    .wrap .fa{
        width: 36px;
    }
    section a {
        color:#999
    }
    .modl_tel {
        background: #ffffff none repeat scroll 0 0;
        border-bottom: 1px solid #ccc;
        height: 60px;
        line-height: 60px;
        margin: 10px 0;
        padding-left: 10px;
    }
    .topban {
        padding: 0 10px;
    }
    .topban {
        background-color: #ffffff;
        overflow: hidden;
        position: relative;
        width: 100%;
    }
    .topban {
        background: #fff none repeat scroll 0 0;
        height: 140px;
        overflow: unset;
        position: relative;
        width: 100%;
    }
    .status-people-pic {
        left: 0;
        margin-left: 15px;
        margin-top: -50px;
        position: absolute;
        top: 50%;
    }
    .stat-people {
        background: #fafafa none repeat scroll 0 0;
        border-radius: 30em;
        display: block;
        padding: 7px;
        position: relative;
        width: 100px;
    }
    .topban {
        overflow: unset;
        position: relative;
        width: 100%;
    }
    .nav {
        background: rgb(249, 249, 249) none repeat scroll 0 0;
        border-top: 1px solid #ddd;
        bottom: 0;
        opacity: 0.9;
        padding: 6px 0 !important;
        position: fixed;
        width: 100%;
        height: 55px;
    }
    .nav .nav-box {
        color: #333;
        float: left;
        font-size: 14px;
        text-align: center;
        width: 33%;
        height: 100%;
    }
    .nav .nav-box.actt{
        color: #068043;
    }

    .topban {
        overflow: unset;
        padding: 20px;
        position: relative;
        width: 100%;
    }

    .lgt.ok {
        background: #068043 none repeat scroll 0 0;
        border-radius: 8px;
        height: 50px;
        line-height: 50px;
        margin: 20px auto;
        text-align: center;
        width: 90%;
    }
    #sign{
        color: #ffffff;
        font-size: 18px;
    }
    .wrap {
        padding: 0 20px;
        position: relative;
    }
    .jt {
        border: 1px solid #101010;
        font-size: 16px;
        height: 5rem;
        line-height: 5rem;
        margin: 20px auto 0;
        text-align: center;
        width: 10rem;
    }
    .child_box {
        margin-top: 30px;
        width: 100%;
    }
    .child_zw{
        cursor:pointer;
    }
    .child_box .child_zw {
        border: 0 none;
        float: left;
        height: 7rem;
        margin: 0 0 20px;
        padding: 0 5px;
        width: 20%;
    }
    .child_box .child_zw .zw{
        width:50%;
        height: 2.5rem;
        border: 1px solid #111111;
        float:left;
    }
    .btn_footer {
        margin: 0 auto;
        padding: 0 30px;
    }
    .zw_name span {
        display: block;
        font-size: 12px;
        text-align: center;
        width: 100%;
    }
    .btn_footer a{
        color: #ffffff;
        font-size:18px
    }
    .clock {
        background-color: inherit;
        border-radius: 2px;
        color: #0277bd;
        display: block;
        font-size: 40px;
        height: 50px;
        line-height: 49px;
        margin: 0 auto;
        max-width: 700px;
        position: relative;
        text-align: center;
        transition: all 0.4s ease-in 0s, box-shadow 0.2s ease 0s;
        width: 100%;
    }
    .clock.inactive {
        color: #0277BD;
    }
    .child_box .child_zw .zw {
        border: 1px solid #111111;
        float: left;
        height: 3rem;
        width: 100%;
    }
    .child_box .child_zw {
        border: 0 none;
        float: left;
        height: 6rem;
        margin: 0 0 20px;
        padding: 0 5px;
        width: 16%;
    }
    .body_box{
        width: 100%;
        height: 400px;
        overflow-y: auto;
    }
    .modal-body {
        padding: 0 15px;
        position: relative;
    }
    form {
        height: auto;
        margin: 10px auto 0;
        padding: 10px;
    }
    .modal-body .Ctable{
        height: 200px;
        overflow-y: auto;
    }
</style>


<div class="data">
    <header class="homeHder header">
        <div class="hder_logo">课程观测</div>
        <div class="hder_urse flor"><a  id="logOut"  href="javascript:void(0);"><i class="fa fa-sign-out"></i></a></div>
        <script type="text/javascript">
            $(function(){
                $("#logOut").click(function(){
                    if(window.confirm('你确定要退出吗？')){
                        $.ajax({
                            type: "POST",
                            url: '<?php echo Yii::app()->createUrl('observation/logOut') ?>',
                            data: {
                                'openid':'<?php echo $openid ?>'
                            },
                            dataType: "json",
                            success: function (data) {
                                if (data) {
                                    if(data.status==1){
                                        window.location.reload();
                                    }else{
                                        alert(data.message);
                                        return false;
                                    }
                                }else{
                                    alert('操作失败');
                                    return false;
                                }
                            }
                        });
                    }
                });
            });
        </script>
    </header>
    <div class="body_box" id="box1" <?php if($types==1 || !$types){ ?>style="display: block"<?php }else{ ?>style="display: none" <?php } ?> >
        <section class="wrap" style="height: 385px;overflow: hidden;">
            <div class="btn_footer">
                <?php if($open_info->status==0){ ?>
                    <a  href="javascript:void(0);"><div id="start_open" style="width: 100%" class="lgt ok">课程开始</div></a>
                <?php }elseif($open_info->status==1){ ?>
                    <a  href="javascript:void(0);"><div  id="end_open" class="lgt">课程结束</div></a>
                <?php }else{ ?>
                    <a  href="javascript:void(0);"><div  style="width: 100%;background: #5e5e5e" class="lgt">课程已结束</div></a>
                <?php } ?>

                <div class="clearfix"></div>
            </div>
            <script type="text/javascript">
                var slock = true;
                $("#end_open").click(function(){
                    if(window.confirm('你确定要结束课程吗？')){
                        if(slock == false){
                            return false;
                        }
                        $.ajax({
                            type: "POST",
                            url: '<?php echo $this->createUrl('ajaxOpenEnd'); ?>',
                            data: {
                                oid:'<?php echo $open_info->id ?>',
                            },
                            dataType: "json",
                            beforeSend: function() {
                                slock = true;
                            },
                            success: function (data) {
                                if (data) {
                                    if(data.status==1){
                                        Xalert(data.message);
                                        setTimeout(function(){
                                            window.location.reload();
                                        },2000)
                                    }else{
                                        Xalert(data.message);
                                        return false;
                                    }
                                }else{
                                    Xalert('操作失败');
                                    return false;
                                }
                            }
                        });
                    }
                });

            </script>
            <div class="body_box">
            <h3>听课老师</h3>
            <table class="table table-bordered">
                <thead>
                <tr>
                    <th>#</th>
                    <th>姓名</th>
                    <th>状态</th>
                </tr>
                </thead>
                <tbody>
                <?php
                foreach($lid as $k=>$v){
                    $uinfo = People::model()->findByPk($v);
                    $signIn = OpenSignin::model()->find('oid=:oid and uid=:uid and type=:type',array(':oid'=>$id,':uid'=>$uinfo->id,':type'=>'tk'));
                    ?>
                    <tr>
                        <th scope="row"><?php echo $k+1; ?></th>
                        <td><?php echo $uinfo->user_name ?></td>
                        <?php if($signIn){ ?>
                            <td>已签到</td>
                        <?php }else{ ?>
                            <td>未签到</td>
                        <?php } ?>
                    </tr>
                <?php } ?>
                </tbody>
            </table>

            <h3>专家</h3>
            <table class="table table-bordered">
                <thead>
                <tr>
                    <th>#</th>
                    <th>姓名</th>
                    <th>状态</th>
                </tr>
                </thead>
                <tbody>
                <?php
                foreach($zid as $k=>$v){
                    $uinfo = Human::model()->findByPk($v);
                    $signIn = OpenSignin::model()->find('oid=:oid and uid=:uid and type=:type',array(':oid'=>$id,':uid'=>$uinfo->id,':type'=>'zj'));
                    ?>
                    <tr>
                        <th scope="row"><?php echo $k+1; ?></th>
                        <td><?php echo $uinfo->user_name ?></td>
                        <?php if($signIn){ ?>
                            <td>已签到</td>
                        <?php }else{ ?>
                            <td>未签到</td>
                        <?php } ?>
                    </tr>
                <?php } ?>
                </tbody>
            </table>
            <div style="width:100%;height:180px"></div>
        </div>
            <div style="width: 100%;height: 80px;"></div>
        </section>
    </div>
    <div class="body_box"  id="box2" <?php if($types==2){ ?>style="display: block"<?php }else{ ?>style="display: none" <?php } ?>>
        <section class="wrap">
            <div style="margin-top:20px;" role="alert" class="alert alert-danger">
                <i class="fa fa-info-circle"></i>
                点击坐次可以选择相应的学生做出答题。<br/>
                每回答一次问题，观察员+1，回答五次后显示全红。
            </div>
            <div class="jt">讲台</div>
            <div style="margin-bottom:60px" class="child_box" id="child_box">
                <?php
                for ($x=1; $x<=7; $x++) {
                    for ($y=1; $y<=6; $y++) {
                        ?>
                        <?php
                        $strleft = 'left'.$x.$y;
                        $$strleft = OpenOrder::model()->find('oid=:oid and x=:x and y=:y and type=:type',array(':oid'=>$id,':x'=>$x,':y'=>$y,':type'=>'left'));
                        ?>
                        <div id="zw<?php echo $x ?><?php echo $y ?>" data-x="<?php echo $x ?>" data-y="<?php echo $y ?>"  data-left-id="<?php echo $$strleft->id ?>"  data-left-name="<?php echo $$strleft->user_name ?>" class="child_zw">
                            <?php if(intval($$strleft->num) >=5){ ?>
                            <div style="background-color: red;" class="zwleft zw"></div>
                            <?php }else{ ?>
                            <div class="zwleft zw"></div>
                            <?php } ?>
                            <div class="zw_name">
                                <?php if($$strleft){ ?>
                                    <?php if($$strleft->user_name){ ?>
                                    <span class="zw_name_left"><?php echo $$strleft->user_name ?> (<b><?php echo intval($$strleft->num); ?></b>)</span>
                                    <?php }else{ ?>
                                    <span class="zw_name_left"><?php echo $x.'排'.$y.'列' ?> (<b><?php echo intval($$strleft->num); ?></b>)</span>
                                    <?php } ?>
                                <?php }else{ ?>
                                    <span class="zw_name_left"><?php echo $x.'排'.$y.'列' ?>(<b>0</b>)</span>
                                <?php } ?>
                            </div>
                        </div>
                        <?php
                    }
                }
                ?>
                <div class="clearfix"></div>
            </div>

        </section>
    </div>
    <div class="body_box"  id="box3" <?php if($types==3){ ?>style="display: block"<?php }else{ ?>style="display: none" <?php } ?>>
        <div class="container-fluid">
            <div class="row">

                <!-- Modal -->
                <div aria-hidden="true" aria-labelledby="linkModalLabel" role="dialog" tabindex="-1" >
                    <div class="modal-body">
                        <form>

                            <div class="col-lg-6" style="margin-bottom: 6px">
                                <select class="form-control" id="selectid" name="gid">
                                    <option selected="selected" value="">请选择类型</option>
                                    <option value="1">回答</option>
                                    <option value="2">活动</option>
                                    <option value="3">拖堂时间</option>
                                </select>
                            </div>
                            <div class="col-lg-6" style="margin-bottom: 6px">
                                <div class="container stopwatch" style="text-align: center; margin-bottom: 0px; margin-top: 0px;">
                                    <div class="clock inactive z-depth-1">
                                        <span>0:00:00.0</span>
                                        <div class="overlay waves-effect"></div>
                                    </div>
                                </div>

                            </div>
                            <div class="col-lg-6" style="margin-bottom: 0">
                                <div class="input-group">
                                  <span class="input-group-btn" >
                                    <button style="float: left;margin-bottom: 0" class="btn btn-primary" id="start_game" type="button">开始</button>
                                      <button style="float: right;margin-bottom: 0" class="btn btn-default" id="end_game" type="button">停止</button>
                                  </span>
                                </div>

                            </div>
                        </form>
                    </div>
                </div>
                <script type="text/javascript">
                    // Stopwatch
                    var stopwatchInterval = 0;      // The interval for our loop.

                    var stopwatchClock = $(".container.stopwatch").find(".clock"),
                        stopwatchDigits = stopwatchClock.find('span');

                    // Checks if the previous session was ended while the stopwatch was running.
                    // If so start it again with according time.
                    if(Number(localStorage.stopwatchBeginingTimestamp) && Number(localStorage.stopwatchRunningTime)){

                        var runningTime = Number(localStorage.stopwatchRunningTime) + new Date().getTime() - Number(localStorage.stopwatchBeginingTimestamp);

                        localStorage.stopwatchRunningTime = runningTime;

                        startStopwatch();
                    }

                    // If there is any running time form previous session, write it on the clock.
                    // If there isn't initialise to 0.
                    if(localStorage.stopwatchRunningTime){
                        stopwatchDigits.text(returnFormattedToMilliseconds(Number(localStorage.stopwatchRunningTime)));
                    }
                    else{
                        localStorage.stopwatchRunningTime = 0;
                    }

                    $('#start_game').on('click',function(){
                        var selectid =  $("#selectid").val();
                        if(selectid==''){
                            Xalert('类型不得为空');
                            return false;
                        }
                        if(stopwatchClock.hasClass('inactive')){
                            resetStopwatch();
                            startStopwatch()
                        }
                    });

                    $('#end_game').on('click',function(){
                        pauseStopwatch();
                    });



                    // Pressing the clock will pause/unpause the stopwatch.
                    stopwatchClock.on('click',function(){

                        if(stopwatchClock.hasClass('inactive')){
                            startStopwatch()
                        }
                        else{
                            pauseStopwatch();
                        }
                    });

                    function startStopwatch(){
                        // Prevent multiple intervals going on at the same time.
                        clearInterval(stopwatchInterval);

                        var startTimestamp = new Date().getTime(),
                            runningTime = 0;

                        localStorage.stopwatchBeginingTimestamp = startTimestamp;

                        // The app remembers for how long the previous session was running.
                        if(Number(localStorage.stopwatchRunningTime)){
                            runningTime = Number(localStorage.stopwatchRunningTime);
                        }
                        else{
                            localStorage.stopwatchRunningTime = 1;
                        }

                        // Every 100ms recalculate the running time, the formula is:
                        // time = now - when you last started the clock + the previous running time

                        stopwatchInterval = setInterval(function () {
                            var stopwatchTime = (new Date().getTime() - startTimestamp + runningTime);





                            stopwatchDigits.text(returnFormattedToMilliseconds(stopwatchTime));
                        }, 100);

                        stopwatchClock.removeClass('inactive');
                    }

                    function pauseStopwatch(){
                        var selectid =  $("#selectid").val();
                        if(selectid==''){
                            Xalert('类型不得为空');
                            return false;
                        }
                        // Stop the interval.
                        clearInterval(stopwatchInterval);
                        if(Number(localStorage.stopwatchBeginingTimestamp)){

                            // On pause recalculate the running time.
                            // new running time = previous running time + now - the last time we started the clock.
                            var runningTime = Number(localStorage.stopwatchRunningTime) + new Date().getTime() - Number(localStorage.stopwatchBeginingTimestamp);
                            var html = '';
                            html +='<tr><th scope="row">#</th>';
                            if(parseInt(selectid)==1){
                                html +='<td>答题时长</td>';
                            }else if(parseInt(selectid)==2){
                                html +='<td>活动时长</td>';
                            }else if(parseInt(selectid)==3){
                                html +='<td>拖堂时长</td>';
                            }


                            html +='<td>'+returnFormattedToMilliseconds(runningTime)+'</td>';
                            html +='</tr>';
                            $("#dati").append(html);


                            $.ajax({
                                type: "POST",
                                url: '<?php echo $this->createUrl('ajaxOpenRunning'); ?>',
                                data: {
                                    type:selectid,
                                    oid:'<?php echo $open_info->id; ?>',
                                    running:runningTime
                                },
                                dataType: "json",
                                success: function (data) {
                                    if (data) {

                                    }else{
                                        Xalert('操作失败');
                                        return false;
                                    }
                                }
                            });
                            localStorage.stopwatchBeginingTimestamp = 0;
                            localStorage.stopwatchRunningTime = runningTime;
                            stopwatchClock.addClass('inactive');
                        }
                    }
                    function onloadTime(time,_this){
                        var ctime = returnFormattedToMilliseconds(time);
                        _this.text(ctime);
                    }
                    // Reset everything.
                    function resetStopwatch(){
                        clearInterval(stopwatchInterval);

                        stopwatchDigits.text(returnFormattedToMilliseconds(0));
                        localStorage.stopwatchBeginingTimestamp = 0;
                        localStorage.stopwatchRunningTime = 0;

                        stopwatchClock.addClass('inactive');
                    }


                    function returnFormattedToMilliseconds(time){
                        var milliseconds = Math.floor((time % 1000) / 100),
                            seconds = Math.floor((time/1000) % 60),
                            minutes = Math.floor((time/(1000*60)) % 60),
                            hours = Math.floor((time/(1000*60*60)) % 24);

                        seconds = seconds < 10 ? '0' + seconds : seconds;
                        minutes = minutes < 10 ? '0' + minutes : minutes;


                        return hours + ":" + minutes + ":" + seconds + "." + milliseconds;
                    }

                </script>
                <div style="border-bottom: 1px solid #000"></div>
                <div aria-hidden="true" aria-labelledby="linkModalLabel" role="dialog" tabindex="-1" >
                    <div class="modal-body">
                        <h4 style="margin-bottom: 0">计时记录</h4>
                        <div class="Ctable">
                        <table class="table table-striped">
                            <thead>
                            <tr>
                                <th>#</th>
                                <th>类型</th>
                                <th>时间</th>

                            </tr>
                            </thead>
                            <tbody id="dati">
                            <?php if($openRunning){ ?>
                                <?php foreach($openRunning as $v){ ?>
                            <tr>
                                <th scope="row">#</th>
                                <?php if($v->type==1){ ?>
                                    <td>答题时长</td>
                                <?php }elseif($v->type==2){ ?>
                                    <td>活动时长</td>
                                <?php }else{ ?>
                                    <td>拖堂时长</td>
                                <?php } ?>
                                <td><?php echo $this->timeRunning($v->running) ?></td>
                            </tr>
                            <?php }} ?>
                            </tbody>
                        </table>
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>
    <nav class="nav">
        <a href="javascript:void(0);" id="qd" class="">
            <div data-type="1" class="nav-box <?php if($types==1 || !$types){ ?>actt<?php } ?>">
                <i class="fa fa-book"></i>签到
            </div>
        </a>
        <a href="javascript:void(0);" id="hd" class="">
            <div data-type="2" class="nav-box <?php if($types==2){ ?>actt<?php } ?>">
                <i class="fa fa-home"></i>互动
            </div>
        </a>
        <a href="javascript:void(0);" id="jl" class="">
            <div  data-type="3" class="nav-box <?php if($types==3){ ?>actt<?php } ?>">
                <i class="fa fa-home"></i>记录
            </div>
        </a>
    </nav>
</div>

<div class="modal fade" id="linkModal-c" tabindex="-1" role="dialog" aria-labelledby="linkModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <!-- 登陆页面注册提示 -->
        <div class="modal-content text-left">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">选择答题学生</h4>
            </div>
            <div class="modal-body">
                <form>
                    <div class="form-group">
                        <label for="exampleInputname1">学生：</label>
                        <button  type="button" id="lname"  onclick="leftForm();"  class="btn btn-primary btn-block btn-lg">确认提交</button>
                        <input type="hidden" class="form-control" id="left_name">
                        <input type="hidden" class="form-control"  id="left_id" >
                        <input type="hidden" class="form-control"  id="x" >
                        <input type="hidden" class="form-control"  id="y" >
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<input type="hidden" id="wt_name" value="">

<script type="text/javascript">
    <?php
    if($open_info->status ==1){
    ?>
    window.setInterval("loadMsg1()",15000);//轮询
    var pagination1 = {
        oid:'<?php echo $open_info->id ?>'
    };
    function loadMsg1(){

            var url = "<?php echo Yii::app()->createUrl('observation/ajaxMsg1') ?>";
            var html = "";
            $.getJSON(url, pagination1, function(jsondata){
                if(jsondata.status==1){
                    window.location.reload();
                    return false;
                }
            });


    }

    <?php } ?>
    function leftForm(){
        $("#linkModal-c").modal('hide');
        $(".body_box").hide();
        $("#box3").show();

        $("#selectid").val('1');
        $(".nav-box").removeClass('actt');
        $("#jl").find('.nav-box').addClass("actt");
        var left_name = $("#left_name").val();
        $("#wt_name").val(left_name);
        var left_id = $("#left_id").val();
        var x = $("#x").val();
        var y = $("#y").val();
        $.ajax({
            type: "POST",
            url: '<?php echo $this->createUrl('ajaxOpenOrder'); ?>',
            data: {
                uid:left_id,
                x:x,
                y:y,
                type:'left',
                oid:'<?php echo $open_info->id ?>',
            },
            dataType: "json",
            success: function (data) {
                if (data) {
                    if(data['status']==1) {
                        $("#zw" + x + y).find(".zw_name .zw_name_left b").html(data['num']);
                        if (data['num'] >= 5) {
                            $("#zw" + x + y).find(".zwleft").css("background-color", "red");
                        }
                    }else if(data['status']==2){
                        $("#zw" + x + y).find(".zw_name .zw_name_left b").html(data['num']);
                        if (data['num'] >= 5) {
                            $("#zw" + x + y).find(".zwleft").css("background-color", "red");
                        }
                    }else{
                        Xalert('操作失败');
                        return false;
                    }
                }else{
                    Xalert('操作失败');
                    return false;
                }
            }
        });
    }

    $(function(){
        //选择答题者
            $(document).on("click",'.child_zw',function(){
                var left_id = $(this).attr("data-left-id");
                var left_name = $(this).attr("data-left-name");
                var x = $(this).attr("data-x");
                var y = $(this).attr("data-y");
                $("#x").val(x);
                $("#y").val(y);
                if(left_name==''){
                    $("#left_id").val('');
                    $("#lname").html(x+'行'+y+'列学生');
                    $("#left_name").val('');
                }else{
                    if(left_id){
                        $("#left_id").val(left_id);
                    }
                    if(left_name){
                        $("#lname").html(left_name);
                        $("#left_name").val(left_name);
                    }
                }
                $("#linkModal-c").modal();
            });

        $(".nav-box").click(function(){
            $("#wt_name").val('');
            $(".nav-box").removeClass('actt');
            $(this).addClass("actt");
            var kid = $(this).attr("data-type");
            $(".body_box").hide();
            $("#box"+kid).show();
        });
    })
</script>
<div class="modal fade" id="Xalert" data-id="1" tabindex="-1" role="dialog" aria-labelledby="linkModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <!-- 登陆页面注册提示 -->
        <div class="modal-content text-left">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">提示</h4>
            </div>
            <div class="modal-body">
                <p id="alertMassage"></p>
                <button type="button" style="margin-top: 20px" class="btn btn-primary" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    function Xalert(html){
        $("#alertMassage").html(html);
        $("#Xalert").modal();
        setTimeout(function(){$("#Xalert").modal('hide')},2000);
    }

</script>
